package com.hongning.railway.ui.main.mine.partcheck;

import android.arch.lifecycle.ViewModelProviders;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hongning.railway.R;
import com.hongning.railway.app.AppViewModelFactory;
import com.hongning.railway.app.Constant;
import com.hongning.railway.databinding.FragmentPartycheckDetailBinding;
import com.hongning.railway.entity.resbean.ResKaoHeBean;

import me.goldze.mvvmhabit.BR;
import me.goldze.mvvmhabit.base.BaseFragment;

public class PartyCheckDetailFragment extends BaseFragment<FragmentPartycheckDetailBinding,PartyCheckDetailFragmentViewModel> {
    ResKaoHeBean mResKaoHeBean;

    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_partycheck_detail;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();

        binding.appTitle.ivLeft.setVisibility(View.VISIBLE);
        binding.appTitle.ivLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getActivity().finish();
            }
        });
        if (mResKaoHeBean!=null){
            binding.appTitle.tvTopTitle.setText(mResKaoHeBean.getGroupName());
            viewModel.setData(mResKaoHeBean);
        }

    }


    @Override
    public void initParam() {
        super.initParam();
        mResKaoHeBean = getArguments().getParcelable(Constant.EXTRA_DATA);
    }

    @Override
    public PartyCheckDetailFragmentViewModel initViewModel() {
        AppViewModelFactory appViewModelFactory = AppViewModelFactory.getInstance(getActivity().getApplication());
        return ViewModelProviders.of(this,appViewModelFactory).get(PartyCheckDetailFragmentViewModel.class);
    }
}
